# Definition for singly-linked list.
from typing import Optional


class ListNode:
    def __init__(self, val=0, next=None):
        self.val = val
        self.next = next

class Solution:
    def reverseBetween(self, head: Optional[ListNode], left: int, right: int) -> Optional[ListNode]:
        i = 1
        res_List = ListNode(0)
        while i < right:
            if i <= left:
                res_List.val = head.val
                res_List.next = head
                head = head.next
            if i >left:


                res_List.next = head
                res_List





